import HttpService from "@/api";
import type { DictEntry } from "@/typings/dict";

/**
 * @description 获取字典类型列表
 * @param params
 * @returns
 */
export const getDictTypeListApi = (params: any) => HttpService.get<any>(`/system/dict/type/list`, { params });

/**
 * @description 新增字典类型
 * @param data
 * @returns
 */
export const addDictTypeApi = (data: DictEntry) => HttpService.post<any>(`/system/dict/type`, data);

/**
 * @description 修改字典类型
 * @param data
 * @returns
 */
export const updateDictTypeApi = (data: DictEntry) => HttpService.put<any>(`/system/dict/type`, data);

/**
 * @description 删除字典类型
 * @param id
 * @returns
 */
export const delDictTypeApi = (id: number) => HttpService.delete<any>(`/system/dict/type/${id}`);

/**
 * @description 刷新字典缓存
 * @param
 * @returns
 */
export const refreshCacheApi = () => HttpService.delete<any>(`/system/dict/type/refreshCache`);

/**
 * @description 查询字段类型详细
 * @param id
 * @returns
 */
export const getDictTypeInfoApi = (id: string) => HttpService.get<any>(`/system/dict/type/${id}`);

/**
 * @description 获取字典数据列表
 * @param id
 * @returns
 */
export const getDictDataListApi = (params: any) => HttpService.get<any>(`/system/dict/data/list`, { params });

/**
 * @description 获取字典选择框列表
 * @param
 * @returns
 */
export const getDictTypeOptionSelectApi = () => HttpService.get<any>(`/system/dict/type/optionSelect`);

/**
 * @description 新增字典类型数据
 * @param
 * @returns
 */
export const addDictDataApi = (data: any) => HttpService.post<any>(`/system/dict/data`, data);

/**
 * @description 更新字典类型数据
 * @param
 * @returns
 */
export const updateDictDataApi = (data: any) => HttpService.put<any>(`/system/dict/data`, data);

/**
 * @description 删除字典类型数据
 * @param
 * @returns
 */
export const delDictDataApi = (id: number) => HttpService.delete<any>(`/system/dict/data/${id}`);

/**
 * @description 查询字典数据详细
 * @param
 * @returns
 */
export const getDictDataByDictCodeApi = (dictCode: number) => HttpService.get<any>(`/system/dict/data/${dictCode}`);
